﻿namespace MDXStudio
{
    using MDXParser;
    using System;
    using System.Windows.Forms;

    internal class CodeGenerator
    {
        public string GetCalcMemberName(System.Windows.Forms.TreeNode treeNode)
        {
            while (treeNode != null)
            {
                MDXNode tag = (MDXNode) treeNode.Tag;
                if ((tag != null) && (tag.GetType() == typeof(MDXWithMemberNode)))
                {
                    MDXWithMemberNode node2 = (MDXWithMemberNode) tag;
                    return node2.GetJustName();
                }
                treeNode = treeNode.Parent;
            }
            return null;
        }

        public string GetCalcMemberParentName(System.Windows.Forms.TreeNode treeNode)
        {
            while (treeNode != null)
            {
                MDXNode tag = (MDXNode) treeNode.Tag;
                if ((tag != null) && (tag.GetType() == typeof(MDXWithMemberNode)))
                {
                    MDXWithMemberNode node2 = (MDXWithMemberNode) tag;
                    return node2.GetParent();
                }
                treeNode = treeNode.Parent;
            }
            return null;
        }
    }
}

